//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Spreadsheet.Extensibility;

namespace OpenLS.Spreadsheet.StandardAddIn.Database
{
    internal class SingleDatabaseCriteria : DatabaseCriteria
    {
        private readonly Criteria _criteria;
        private readonly int ColumnIndex;

        public SingleDatabaseCriteria(IWorkbook workbook, string value, int columnIndex)
        {
            _criteria = new Criteria(workbook, value);
            ColumnIndex = columnIndex;
        }

        public Criteria Criteria
        {
            get { return _criteria; }
        }

        public override bool Matches(IRange source, int rowIndex)
        {
            object o = source[rowIndex, ColumnIndex].Value;
            return Criteria.Matches(o);
        }
    }
}